package com.atguigu.staservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staservice.service.StatisticsCourseinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author gengky
 * @since 2022-05-07
 */
@RestController
@RequestMapping("/staservice/staCourseinfo")
public class StatisticsCourseinfoController {


    @Autowired
    StatisticsCourseinfoService staService;


    /**
     * 统计某一天的课程信息，生成统计数据
     * @param day
     * @return
     */
    @PostMapping("setCourseDataSta/{title}/{day}")
    public R registerCount(@PathVariable String title,@PathVariable String day){
        staService.setCourseCount(title,day);
        return R.ok();
    }

    /**
     * 生成课程统计类数据
     * @param type
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("getCourseDataSta/{courseTitle}/{type}/{begin}/{end}")
    public R getCourseDataSta(@PathVariable String courseTitle,
            @PathVariable String type, @PathVariable String begin,
                              @PathVariable String end){
        System.out.println("### getCourseDataSta");
        Map<String,Object> map=staService.getShowCourseData(courseTitle,type,begin,end);
        return R.ok().data(map);
    }
}

